package top.ruanlitao.shortlink.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.ruanlitao.shortlink.admin.common.convention.result.Result;
import top.ruanlitao.shortlink.admin.remote.ShortLinkActualRemoteService;
import top.ruanlitao.shortlink.admin.remote.dto.req.RecycleBinRecoverReqDTO;
import top.ruanlitao.shortlink.admin.remote.dto.req.RecycleBinRemoveReqDTO;
import top.ruanlitao.shortlink.admin.remote.dto.req.RecycleBinSaveReqDTO;
import top.ruanlitao.shortlink.admin.remote.dto.req.ShortLinkRecycleBinPageReqDTO;
import top.ruanlitao.shortlink.admin.remote.dto.resp.ShortLinkPageRespDTO;
import top.ruanlitao.shortlink.admin.service.RecycleBinService;

/**
 * 回收站控制层
 */
@RestController
@RequestMapping("/api/short-link/admin/v1/recycle-bin")
@RequiredArgsConstructor
public class RecycleBinController {

    private final RecycleBinService recycleBinService;

    // 短链接中台远程调用服务（使用 SpringCloud OpenFeign）
    private final ShortLinkActualRemoteService shortLinkActualRemoteService;

    /**
     * 将短链接保存回收站
     */
    @PostMapping("/save")
    public Result<Void> saveRecycleBin(@RequestBody RecycleBinSaveReqDTO requestParam) {
        return shortLinkActualRemoteService.saveRecycleBin(requestParam);
    }

    /**
     * 分页查询回收站短链接
     */
    @GetMapping("/page")
    public Result<Page<ShortLinkPageRespDTO>> pageRecycleBinShortLink(ShortLinkRecycleBinPageReqDTO requestParam) {
        return recycleBinService.pageRecycleBinShortLink(requestParam);
    }

    /**
     * 恢复短链接
     */
    @PostMapping("/recover")
    public Result<Void> recoverRecycleBin(@RequestBody RecycleBinRecoverReqDTO requestParam) {
        return shortLinkActualRemoteService.recoverRecycleBin(requestParam);
    }

    /**
     * 移除短链接
     */
    @PostMapping("/remove")
    public Result<Void> removeRecycleBin(@RequestBody RecycleBinRemoveReqDTO requestParam) {
        return shortLinkActualRemoteService.removeRecycleBin(requestParam);
    }
}
